package vista;

import controlador.*;
import javax.swing.DefaultListModel;

public class VistaPistaOponente extends javax.swing.JFrame {

	private static final long serialVersionUID = 1L;

    private javax.swing.JButton botonCancelar;
    private javax.swing.JButton botonCorrer;
    private javax.swing.JLabel etiquetaApuesta;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JList listaPistas;
    private javax.swing.JList listaOponentes;

 
    public VistaPistaOponente(ControladorVistaPistaOponente controlador) {
        initComponents();
        this.VistaVisibilidadTrue();
        this.setLocationRelativeTo(null); 
        botonCorrer.addActionListener(controlador.getListenerBotonCorrer());
        botonCancelar.addActionListener(controlador.getListenerBotonCancelar());
        listaOponentes.addListSelectionListener(controlador.getListenerListaOponentes());
    }
    
    public void VistaVisibilidadFalse(){
		this.setVisible(false);
    } 
    
    public void VistaVisibilidadTrue(){
		this.setVisible(true);
    }
    
    
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        listaPistas = new javax.swing.JList();
        jScrollPane2 = new javax.swing.JScrollPane();
        listaOponentes = new javax.swing.JList();
        botonCorrer = new javax.swing.JButton();
        botonCancelar = new javax.swing.JButton();
        jLabel3 = new javax.swing.JLabel();
        etiquetaApuesta = new javax.swing.JLabel();
        
        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Car Tunning Experience 2008");

        jLabel1.setFont(new java.awt.Font("Century Gothic", 0, 18));
        jLabel1.setText("PISTAS");

        jLabel2.setFont(new java.awt.Font("Century Gothic", 0, 18));
        jLabel2.setText("OPONENTES");

        listaPistas.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jScrollPane1.setViewportView(listaPistas);

        jScrollPane2.setViewportView(listaOponentes);

        botonCorrer.setText("CORRER");
       

        botonCancelar.setText("CANCELAR");
        

        jLabel3.setFont(new java.awt.Font("Century Gothic", 0, 12));
        jLabel3.setText("APUESTA:");

        etiquetaApuesta.setFont(new java.awt.Font("Century Gothic", 0, 12));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(63, 63, 63)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(23, 23, 23)
                                .addComponent(jLabel1))
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 116, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(46, 46, 46)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel2)
                            .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(botonCorrer, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(73, 73, 73)
                        .addComponent(botonCancelar, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 25, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel3)
                    .addComponent(etiquetaApuesta, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(23, 23, 23))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(30, 30, 30)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jLabel2))
                .addGap(26, 26, 26)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE))
                .addGap(30, 30, 30)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(botonCorrer)
                    .addComponent(botonCancelar))
                .addGap(19, 19, 19))
            .addGroup(layout.createSequentialGroup()
                .addGap(93, 93, 93)
                .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(etiquetaApuesta, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(192, Short.MAX_VALUE))
        );

        pack();
    }
    
     public void llenarListas (DefaultListModel modeloPista,DefaultListModel modeloOponente){
    	   listaPistas.setModel(modeloPista);
    	   listaOponentes.setModel(modeloOponente);
    	   listaPistas.setSelectedIndex(0);
    	   listaOponentes.setSelectedIndex(0);
       	
        	}
     
     public int DevolverIndicePistas (){
  	   return listaPistas.getSelectedIndex();
      }
      
      public int DevolverIndiceOponentes(){
   	   return listaOponentes.getSelectedIndex();
       }
      
      public void SetApuesta (String valor){
    	  etiquetaApuesta.setText(valor);
      }
    
   
    
}
